refactor: Share left-side spill file across partitions on OOM fallback#21699
Merged
viirya merged 1 commit intoapache:mainfrom Apr 19, 2026
Merged
refactor: Share left-side spill file across partitions on OOM fallback#21699viirya merged 1 commit intoapache:mainfrom
viirya merged 1 commit intoapache:mainfrom
Conversation
17906e9 to
ccc6e9d
Compare
ccc6e9d to
5f900c6
Compare
viirya
commented
Apr 17, 2026
| 01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)], metrics=[<slt:ignore>] | ||
| 02)--AggregateExec: mode=Single, gby=[], aggr=[count(Int64(1))], metrics=[<slt:ignore>] | ||
| 03)----NestedLoopJoinExec: join_type=Inner, filter=v1@0 + v2@1 > 0, projection=[], metrics=[output_rows=100.0 K, <slt:ignore> spill_count=1, <slt:ignore>] | ||
| 03)----NestedLoopJoinExec: join_type=Inner, filter=v1@0 + v2@1 > 0, projection=[], metrics=[output_rows=100.0 K, <slt:ignore> spill_count=2, <slt:ignore>] |
Member
Author
There was a problem hiding this comment.
Now the left side spills during OOM, so spill_count increases from 1 to 2.
2010YOUY01
approved these changes
Apr 18, 2026
Contributor
2010YOUY01
left a comment
There was a problem hiding this comment.
LGTM, thank you!
One potential improvement is to let all partitions share the same buffered left-side chunk. This would allow us to process more left-side data per right-side probe pass under the same memory budget, reducing the number of probe passes.
This likely requires replacing the existing OnceAsync with a different coordination mechanism.
That said, the current solution is a good starting point, since spill encoding and decoding are relatively lightweight, we can iterate on this in the future.
Previously when OnceFut failed with OOM, each partition independently re-executed the left child to get its own stream. This was redundant since all partitions need the same left data. Now the first partition to initiate fallback spills the entire left side to disk via a shared OnceAsync<LeftSpillData>. Other partitions wait on the same future and read from the shared spill file, avoiding redundant re-execution of the left child. Co-authored-by: Claude Code
5f900c6 to
3ab0cc9
Compare
Member
Author
|
Thanks @2010YOUY01 |
Rich-T-kid
pushed a commit
to Rich-T-kid/datafusion
that referenced
this pull request
Apr 21, 2026
apache#21699) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes #. ## Rationale for this change To reduce the redundant re-execution of the left side during OOM fallback. ## What changes are included in this PR? Previously when OnceFut failed with OOM, each partition independently re-executed the left child to get its own stream. This was redundant since all partitions need the same left data. Now the first partition to initiate fallback spills the entire left side to disk via a shared OnceAsync<LeftSpillData>. Other partitions wait on the same future and read from the shared spill file, avoiding redundant re-execution of the left child. Co-authored-by: Claude Code ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Unit test ## Are there any user-facing changes? No <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
To reduce the redundant re-execution of the left side during OOM fallback.
What changes are included in this PR?
Previously when OnceFut failed with OOM, each partition independently re-executed the left child to get its own stream. This was redundant since all partitions need the same left data.
Now the first partition to initiate fallback spills the entire left side to disk via a shared OnceAsync. Other partitions wait on the same future and read from the shared spill file, avoiding redundant re-execution of the left child.
Co-authored-by: Claude Code
Are these changes tested?
Unit test
Are there any user-facing changes?
No